package com.talos.ums.enums;

import java.util.Objects;

public enum AppVersionSourceEnum {

    otwb_tms_driver("otwb_tms_driver", "司机端"),
    otwb_tms_station("otwb_tms_station", "站点端"),
    otwb_tms_station_html("otwb_tms_station_html", "站点端html版本"),
    ;

    private final String code;
    private final String msg;

    AppVersionSourceEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * 枚举类型转换，由于构造函数获取了枚举的子类enums，让遍历更加高效快捷
     * @param code 数据库中存储的自定义code属性
     * @return code对应的枚举类
     */
    public static AppVersionSourceEnum locateEnum(String code) {
        for(AppVersionSourceEnum status : AppVersionSourceEnum.values()) {
            if(Objects.equals( status.getCode() , code)) {
                return status;
            }
        }
        return null;
    }

}
